<!DOCTYPE html>
<html>
<head>
    <title>测试代理连接</title>
</head>
<body>
    <h1>测试代理连接</h1>
    <button onclick="testProxy()">测试代理</button>
    <div id="result"></div>

    <script>
    async function testProxy() {
        const resultDiv = document.getElementById('result');
        resultDiv.innerHTML = '正在测试...';
        
        try {
            console.log('测试代理连接...');
            const response = await fetch('/api/questionnaire/upload', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    fileName: 'proxy_test.csv',
                    content: '姓名,年龄\n张三,20',
                    directory: 'public/data/liangbiao/UnprocessedData'
                })
            });

            console.log('响应状态:', response.status);
            const result = await response.json();
            console.log('响应结果:', result);
            
            resultDiv.innerHTML = `
                <h3>代理测试结果:</h3>
                <p>状态: ${response.status}</p>
                <p>成功: ${response.ok}</p>
                <p>结果: ${JSON.stringify(result, null, 2)}</p>
            `;

        } catch (error) {
            console.error('代理测试失败:', error);
            resultDiv.innerHTML = `<p style="color: red;">代理测试失败: ${error.message}</p>`;
        }
    }
    </script>
</body>
</html>
